#ifndef CUSTOMEVENT_H
#define CUSTOMEVENT_H
#define DECLARE_CUSTOM_EVENT() void customEvent(QEvent *event);
#define CUSTOM_EVENT_MAP(class_name) void class_name::customEvent(QEvent *event)
#define CUSTOM_EVENT_WITH_PARAM(event_type, method_name, event_class, user_data) \
if (event->type() == event_type)\
{\
    event->accept();\
    event_class* myEvent = dynamic_cast<event_class*>(event);\
    if (myEvent) {\
        method_name(myEvent->user_data);\
    }\
    else\
    {\
        std::clog << "dynamic_cast failed whie processing custom events" << std::endl;\
    }\
   return;\
}

#define CUSTOM_EVENT(event_type, method_name)  if (event->type() == event_type)\
{\
    method_name();\
    return;\
}
#include <QEvent>

template <class classEvent, typename eventHandler, typename userData>
        void checkEvent(int const& eventType, QEvent* event)
{
    if (event->type() == eventType)
    {
        classEvent* myEvent = dynamic_cast<classEvent*>(event);
        if (myEvent) {
            eventHandler(myEvent->userData);
        }
    }
}


#endif // CUSTOMEVENT_H
